<template>
  <div class="home">
    <div class="carousel">
      <el-carousel height="50vh">
        <el-carousel-item v-for="item in 4" :key="item">
          <el-image
            style="width: 100%; height: 100%"
            :src="require('@/imgs/background.png')"
            :fit="fit"
          ></el-image>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="news">
      <div class="news-left">
        <div class="title">
          <div class="title-left">新闻动态</div>
          <div class="title-right"><el-button size="medium" type="text" @click="gotoNewpage('/news')">More</el-button></div>
        </div>
        <div class="news-content">
          <div class="news-content" v-for="(item, index) in this.news.slice(0, 10)" :key="index">
            <!-- 渲染数组的前10个元素 -->
            * <a :href="item.url" target="_blank">{{ item.content }}</a>
          </div>
          <div class="news-content">...</div>
        </div>
      </div>
      <div class="news-right">
        <div class="title">
          <div class="title-left">研究成果</div>
          <div class="title-right"><el-button size="medium" type="text" @click="gotoNewpage('/paper')">More</el-button></div>
        </div>
        <div class="news-content">
          <div class="news-content" v-for="(item, index) in this.papers.slice(0, 6)" :key="index">
            <!-- 渲染数组的前10个元素 -->
            * <a :href="item.url" target="_blank">{{ item.content }}</a>
          </div>
          <div class="news-content">...</div>
        </div>
      </div>
      
    </div>
    <div class="link">
      <h2>友情链接</h2>
      <div class="line1"></div>
      <div class="logo"></div>
      <ul>
        <li>
          <a href="https://www.gdut.edu.cn/">
            <div class="img">
              <img
                style="width: 66%; height: 66%"
                src="@/imgs/links/link1.jpeg"
              />
            </div>
          </a>
        </li>

        <li>
          <a href="https://iehpc.gdut.edu.cn/">
            <div class="img">
              <img
                style="width: 66%; height: 66%"
                src="@/imgs/links/link2.jpeg"
              />
            </div>
          </a>
        </li>

        <li>
          <a href="https://hkxy.gdut.edu.cn/">
            <div class="img">
              <img
                style="width: 66%; height: 66%"
                src="@/imgs/links/link3.jpeg"
              />
            </div>
          </a>
        </li>
        <li>
          <a href="http://www.human-exposome.com/Default.aspx">
            <div class="img">
              <img
                style="
                  width: 100%;
                  height: 100%;
                  background-color: #e0e0e0;
                  margin: 10px;
                "
                src="@/imgs/links/link4.png"
              />
            </div>
          </a>
        </li>

        <div class="clear"></div>
      </ul>
    </div>
    <div class="space">
      <br />
    </div>
  </div>
</template>

<script>
import { getNews } from "@/api/publicSearch";
import { getPapperFirst } from "@/api/publicSearch";
export default {
  name: "homeView",
  data() {
    return {
      url: [
        '@/imgs/background.png',
      ],
      news: [],
      papers: [],
    };
  },
  methods: {
     //页面转跳
     gotoNewpage(str){
      this.$router.push({
        path: str,
      });
    }
  },
  mounted() {
    getNews().then((res) => {
      this.news = res.data.data;
    });
    getPapperFirst().then((res) => {
      this.papers = res.data.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.home {
  width: 100%;

  .news {
    // height: 50vh;
    display: flex;
    .news-left,
    .news-right {
      margin: 1%;
      width: 46%;
      display: block;
      background-color: #ffffff; /* 卡片背景颜色 */
      border-radius: 8px; /* 卡片边框圆角 */
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 卡片阴影效果 */
      padding: 16px; /* 卡片内边距 */
      .title {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        .title-left {
          font-size: large;
          font-weight: bold;
        }
        .title-right {
        }
      }
      .news-content{
        padding: 15px;
      }
    }
  }

  .link h2 {
    margin-top: 3%;
    font-size: 32px;
    line-height: 42px;
    color: #17a1e6;
    text-align: center;
  }
  .link .line1 {
    width: 40px;
    height: 4px;
    margin: 0 auto;
    background: #17a1e6;
    margin-top: 5px;
    margin-bottom: 20px;
  }
  .link .logo {
  }
  .link ul {
    white-space: nowrap;
    overflow-x: auto;
    padding: 0;
    margin: 0;
  }

  .link ul li {
    display: inline-block;
    vertical-align: top;
    margin-right: 10px;
    margin-left: 1%;
  }

  .link ul li:last-child {
    margin-right: 0;
  }

  .link ul li a {
    display: inline-block;
  }

  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n + 1) {
    background-color: #d3dce6;
  }
  .el-button--text{
    font-size: medium;
    color: rgb(0, 112, 192);
  }
  a:link {
        text-decoration: none;
        color: black;
    }    
    a:visited {
        color: black;
    }
    a:hover {
        color: blue;
    }
}
</style>
